package client.comm.baoding.fragment

import android.content.Intent
import androidx.core.view.ViewCompat
import client.comm.commlib.base.BaseFragment
import client.comm.commlib.utils.Util
import client.comm.baoding.R
import client.comm.baoding.adapter.page.CateGoodsPageAdapter
import client.comm.baoding.databinding.FragmentTabtwoBinding
import client.comm.baoding.ui.SearchActivity
import client.comm.baoding.ui.vm.MainViewModel

class TabTwoFragment : BaseFragment<FragmentTabtwoBinding, MainViewModel>() {

    override fun getViewId(): Int {
        return R.layout.fragment_tabtwo
    }


    lateinit var pageAdapter: CateGoodsPageAdapter
    override fun initViewModel(): MainViewModel = createViewModel()

    override fun initWidget() {
        binding.statusBar.post {
            val h = Util.getStatusBarHeight(requireContext())
            val p = binding.statusBar.layoutParams
            p.height = h
            binding.statusBar.layoutParams = p
            Util.setBg(resources!!.getColor(R.color.white), requireActivity().window)
            val controller = ViewCompat.getWindowInsetsController(binding.root)
            controller?.isAppearanceLightStatusBars = true
        }

        binding.emptyLayout.setOnClickListener {
            viewModel.holdCate()
        }
        binding.event = this
    }

    fun goSearch() {
        startActivity(Intent(requireContext(), SearchActivity::class.java))
    }
}